feat(setting): 支持快捷键目标选择和预截图优化#574
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a pre-screenshot optimization feature for Windows global shortcuts, allowing screenshot-related shortcuts to pre-capture the screen frame. It extracts a shared CommandTargetSelector component, updates the shortcut database schema and APIs to support preScreenshotOptimization, and integrates native Windows shortcut listening via OptimizedShortcutManager. Additionally, it expands the supported command types to include regex, over, img, and files. Review feedback points out a potential issue with duplicate native shortcut registration when updating targets, and a TypeScript type mismatch in usePluginCommandActions.ts where the newly added command types are not supported.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| if (this.shouldUseNativeOptimizedShortcut(shortcut, preScreenshotOptimization)) { | ||
| globalShortcut.unregister(shortcut) | ||
| this.registerNativeOptimizedShortcut(shortcut) |
There was a problem hiding this comment.
当 previousWasNative 为 true 时,说明该快捷键已经通过 native 注册。如果此时因为修改目标指令而重新调用 registerGlobalShortcut,在不改变快捷键的情况下,无需再次调用 this.registerNativeOptimizedShortcut(shortcut) 进行底层注册。重复注册可能会导致 native 插件返回失败,从而导致快捷键更新失败。建议仅在 !previousWasNative 时才执行底层注册。
| this.registerNativeOptimizedShortcut(shortcut) | |
| if (!previousWasNative) { | |
| this.registerNativeOptimizedShortcut(shortcut) | |
| } |
| featureCode: string, | ||
| cmdName: string, | ||
| cmdType: CommandCmdType | ||
| cmdType: 'text' | 'window' |
There was a problem hiding this comment.
在此次修改中,系统新增了多种指令类型(如 'regex' | 'over' | 'img' | 'files')。如果将 cmdType 限制为 'text' | 'window',将导致这些新类型的指令无法通过 usePluginCommandActions 进行禁用、启用或状态查询(会产生 TypeScript 类型错误)。建议将 cmdType 的类型定义扩展为包含所有支持的指令类型,或者直接使用项目中定义的 ShortcutsSettingCommandCmdType(或其联合类型)。此建议同样适用于该文件中的其他几处修改(第 99 行、第 109 行和第 439 行)。
cmdType: 'text' | 'regex' | 'over' | 'img' | 'files' | 'window'
resolve #536
ZTools-native-api: 关联相关提交